2af70b
@@ -26,6 +26,7 @@
import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.commands.AbstractLocalCamelController;
 import org.apache.camel.api.management.ManagedCamelContext;
+import org.apache.camel.support.ObjectHelper;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -101,4 +102,57 @@
public class CamelControllerImpl extends AbstractLocalCamelController {
         return answer;
     }
 
+    @Override
+    public void startContext(String camelContextName) throws Exception {
+        final CamelContext context = getLocalCamelContext(camelContextName);
+        if (context != null) {
+            ObjectHelper.callWithTCCL(() -> {
+                context.start();
+                return null;
+            }, getClassLoader(context));
+        }
+    }
+
+    @Override
+    public void resumeContext(String camelContextName) throws Exception {
+        final CamelContext context = getLocalCamelContext(camelContextName);
+        if (context != null) {
+            ObjectHelper.callWithTCCL(() -> {
+                context.resume();
+                return null;
+            }, getClassLoader(context));
+        }
+    }
+
+    @Override
+    public void startRoute(String camelContextName, final String routeId) throws Exception {
+        final CamelContext context = getLocalCamelContext(camelContextName);
+        if (context != null) {
+            ObjectHelper.callWithTCCL(() -> {
+                context.getRouteController().startRoute(routeId);
+                return null;
+            }, getClassLoader(context));
+        }
+    }
+
+    @Override
+    public void resumeRoute(String camelContextName, final String routeId) throws Exception {
+        final CamelContext context = getLocalCamelContext(camelContextName);
+        if (context != null) {
+            ObjectHelper.callWithTCCL(() -> {
+                context.getRouteController().resumeRoute(routeId);
+                return null;
+            }, getClassLoader(context));
+        }
+    }
+
+    /**
+     * Gets classloader associated with {@link CamelContext}
+     * @param context
+     * @return
+     */
+    private ClassLoader getClassLoader(CamelContext context) {
+        return context.getApplicationContextClassLoader();
+    }
+
 }
